<!--googleoff: all-->

{{ $lang := .Page.Language.Lang }}
{{ if eq $lang "en" }}
  {{/*
    If we are in English, we search avaliable translations and add them hidden.
    The javascript will show the relevant ones using the two first letters.
    Ex. if the browser is in "pt-pt", it will show the messages for "pt-pt" and "pt-br"
  */}}

  {{ range .Page.Translations }}
    {{ if and (ne "en" .Language.Lang) ( not .Page.Params.untranslated ) }}
      <p data-langswitch="{{ .Language.Params.languageCode }}" style="display:none">
        <a lang="{{ .Language.Params.languageCode }}" hreflang="{{ .Language.Params.languageCode }}" href="{{ .RelPermalink }}">
        {{ if .Language.Params.viewInThatLanguage  }}
          {{ .Language.Params.viewInThatLanguage }}
        {{ else }}
          {{ errorf "Missing 'viewInThatLanguage' for lang %q in 'config/_default/languages.%s.toml'" .Page.Language.Lang .Page.Language.Lang }}
        {{ end }}
        </a>
      </p>
      
    {{ end }}
  {{ end }}
{{ end }}
<script src="/js/i18n.js" defer async></script>

<!--googleon: all-->
